<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改服务')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal" id="form-service-edit" th:object="${service}">

        <div class="col-sm-13">
            <div class="ibox-content" style="border-width: 0">
                <div class="nav-tabs-custom">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#ana_info" data-toggle="tab" aria-expanded="true">基本资料</a></li>
                        <li><a href="#params" data-toggle="tab" aria-expanded="false">实验参数</a></li>
                    </ul>
                    <div class="tab-content">
                        <!--基本资料-->
                        <div class="tab-pane active" id="ana_info">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">服务名称：</label>
                                <div class="col-sm-8">
                                    <input readonly class="form-control" type="text" name="serviceName" th:field="*{serviceName}">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">服务类型：</label>
                                <div class="col-sm-8">
                                    <input readonly class="form-control" type="text" name="serviceType.svtypeName" th:field="*{serviceType.svtypeName}">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">仪器：</label>
                                <div class="col-sm-8">
                                    <input readonly class="form-control" type="text" name="instrument.instName" th:field="*{instrument.instName}">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">样品：</label>
                                <div class="col-sm-8">
                                    <input readonly class="form-control" type="text" th:field="*{sampleName}">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">模板：</label>
                                <div class="col-sm-8">
                                    <select class="form-control" name="templateId">
                                        <option th:each="template : ${templates}"  th:text="${template.templateName}" th:value="${template.templateId}" th:disabled="${template.templateStatus == '0'}" th:field="*{templateId}"></option>
                                    </select>
                                </div>
                            </div>
                            <!--<div class="form-group">
                                <label class="col-sm-3 control-label">参数列表：</label>
                                <div class="col-sm-8">
                                    <div class="input-group">
                                        <input readonly class="form-control" type="text" name="expParams" th:field="*{expParams}">
                                        <span class="input-group-addon"><i class="fa fa-edit" onclick="editParams()"></i></span>
                                    </div>
                                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 参数列表随模板改变而改变</span>
                                    <div>
                                        <label class="col-sm-1 control-label">ns：</label>
                                        <div class="col-sm-2">
                                            <input id="ns" class="form-control" type="number" name="ns" max="9999" min="10">
                                        </div>
                                        <label class="col-sm-1 control-label">Gain：</label>
                                        <div class="col-sm-2">
                                            <label class="toggle-switch switch-solid">
                                                <input type="checkbox" id="gain">
                                                <span></span>
                                            </label>
                                        </div>
                                    </div>
                                </div>
                            </div>-->
                            <div class="form-group">
                                <label class="col-sm-3 control-label is-required">验证员：</label>
                                <div class="col-sm-8">
                                    <select class="form-control" name="verifier" required>
                                        <option th:each="verifier : ${userVerifiers}"  th:text="${verifier.userName}" th:value="${verifier.userId}" th:field="*{verifier}"></option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">优先：</label>
                                <div class="col-sm-8">
                                    <label class="toggle-switch switch-solid">
                                        <input type="checkbox" id="priority" th:checked="*{priority == '1' ? true : false}">
                                        <span></span>
                                    </label>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">备注：</label>
                                <div class="col-sm-8">
                                    <input id="remark" name="remark" class="form-control" type="text" th:field="*{remark}">
                                </div>
                            </div>
                        </div>

                        <!--实验参数-->
                        <div class="tab-pane" id="params">
                            <div class="form-group">
                                <div th:each="expParam:${service.expParamList}">
                                    <label class="col-sm-2 control-label" th:text="${expParam.key}"></label>
                                    <div class="col-sm-2">
                                        <input th:id="${expParam.key}" class="form-control expparam" th:name="${expParam.key}" th:value="${expParam.value}">
                                    </div>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">Gain：</label>
                                <div class="col-sm-3">
                                    <label class="toggle-switch switch-solid">
                                        <input type="checkbox" id="gain2" >
                                        <span></span>
                                    </label>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>


        <div class="form-group">
            <label class="col-sm-3 control-label is-required">状态：</label>
            <div class="col-sm-8">
                <select class="form-control" name="serviceStatus">
                    <option></option>
                    <option th:value="${@dict.getValue('sys_service_status','Completed')}" th:field="*{serviceStatus}">Approved</option>
                    <option th:value="${@dict.getValue('sys_service_status','Reject')}" th:field="*{serviceStatus}">Rejected</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">Comment：</label>
            <div class="col-sm-8">
                <input name="comment" class="form-control" type="text" th:field="*{analyseResult}" >
            </div>
        </div>
        <input id="serviceId" name="serviceId" type="hidden" th:field="*{serviceId}"/>
    </form>
</div>
<th:block th:include="include :: footer" />
<script type="text/javascript">
    var prefix = ctx + "system/analyse";
    var checkUrl = prefix + "/signature";

    function submitHandler() {
        //输入密码弹窗
        if ($.validate.form()) {
            $.operate.passwordCheck('Enter your password', checkUrl, function(){
                var data = $("#form-service-edit").serializeArray();
                var priority = $("input[id='priority']").is(':checked') == true ? 1 : 0;
                var expParams = new Array();
                $(".expparam").each(function (i) {
                    var name = $(this).attr("name");
                    var value = $(this).val();
                    expParams.push(name+":"+value);
                })
                // console.log(expParams)
                data.push({"name": "priority", "value": priority});
                data.push({"name": "expParams", "value": expParams});
                $.operate.save(prefix + "/edit", data);
            });
        }
    }

</script>
</body>
</html>
